package com.zjp.mapper;

import com.zjp.pojo.InoculationHistory;
import com.zjp.pojo.InoculationHistoryExample;
import java.util.List;

import com.zjp.pojo.Reservation;
import com.zjp.vo.ReservationVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface InoculationHistoryMapper {
    long countByExample(InoculationHistoryExample example);

    int deleteByExample(InoculationHistoryExample example);

    int deleteByPrimaryKey(Long historyid);
//
//    @Insert("insert into zjp.inoculation_history (historyId, Num, vaccinesId, InoculationId, inoculationTime, UserId) values (#{historyid}, #{num}, #{vaccinesid}, #{inoculationid}, #{inoculationtime}, #{userid})")
    int insert(InoculationHistory record);

    int insertSelective(InoculationHistory record);

    List<InoculationHistory> selectByExample(InoculationHistoryExample example);

    InoculationHistory selectByPrimaryKey(Long historyid);

    int updateByExampleSelective(@Param("record") InoculationHistory record, @Param("example") InoculationHistoryExample example);

    int updateByExample(@Param("record") InoculationHistory record, @Param("example") InoculationHistoryExample example);

    int updateByPrimaryKeySelective(InoculationHistory record);

    int updateByPrimaryKey(InoculationHistory record);
    /**
     * 查询预约记录
     *
     * @param id
     * @return
     */
    @Select("SELECT i.id, r.vaccinesname, v.manufactor, i.inventory, r.inoculationname, r.starttime, r.endtime " +
            "FROM zjp.inoculation_history h " +
            "JOIN zjp.reservation r ON h.InoculationId = r.InoculationId " +
            "JOIN zjp.vaccines v ON v.vaccinesId = r.vaccinesId " +
            "JOIN zjp.i_vaccines i ON i.vaccinesId = v.vaccinesId " +
            "WHERE h.UserId = #{id}")
    List<ReservationVo> findAllInoculationHistory(Integer id);


    /**
     * 更新预约记录
     *
     * @param reservationVo
     * @return
     */
    @Update("update zjp.reservation set status = 1 where id = #{id}")
    int UpdateStuts(Reservation reservationVo);
}